﻿using FVEcharts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FVEchartsDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : FruitVentDesign.Windows.Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new MainWindowViewModel();
            Loaded += MainWindow_Loaded;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if(DataContext is MainWindowViewModel model)
            {
                model.Option = new EchartOption<BarSerie>()
                {
                    Tooltip = new Tooltip() { },
                    // Legend = new Legend() { Position = LegendPosition.BottomCenter },
                    Title = new Title() { Text = "柱状图", Subtext = "测试柱状图" },
                    XAxis = new XAxis()
                    {
                        Type = AxisType.Category,
                        Data = new List<string>() {
                            "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
                        },
                        AxisLabel = new AxisLabel() { 
                            Interval = "0", 
                            Rotate = 20 
                        }
                    },
                    YAxis = new YAxis()
                    {
                        Type = AxisType.Value,
                    },
                    Series = new List<BarSerie>()
                    {
                        new BarSerie()
                        {
                            Name = "Rainfall",
                            Type = SerieType.Bar,
                            Label = new BarLabel(){},
                            Data = new List<SerieData>() {
                                new SerieData() { Value = 2.0, Name = "Jan" },
                                new SerieData() { Value = 4.9, Name = "Feb" },
                                new SerieData() { Value = 7.0, Name = "Mar" },
                                new SerieData() { Value = 23.2, Name = "Apr" },
                                new SerieData() { Value = 25.6, Name = "May" },
                                new SerieData() { Value = 76.7, Name = "Jun" },
                                new SerieData() { Value = 135.6, Name = "Jul" },
                                new SerieData() { Value = 162.2, Name = "Aug" },
                                new SerieData() { Value = 32.6, Name = "Sep" },
                                new SerieData() { Value = 20.0, Name = "Oct" },
                                new SerieData() { Value = 6.4, Name = "Nov" },
                                new SerieData() { Value = 3.3, Name = "Dec" },
                            },
                        },
                        //new BarSerie()
                        //{
                        //    Name = "Evaporation",
                        //    Type = SerieType.Bar,
                        //    Data = new List<SerieData>() {
                        //        new SerieData() { Value = 2.6, Name = "Jan" },
                        //        new SerieData() { Value = 5.9, Name = "Feb" },
                        //        new SerieData() { Value = 9.0, Name = "Mar" },
                        //        new SerieData() { Value = 26.4, Name = "Apr" },
                        //        new SerieData() { Value = 28.7, Name = "May" },
                        //        new SerieData() { Value = 70.7, Name = "Jun" },
                        //        new SerieData() { Value = 175.6, Name = "Jul" },
                        //        new SerieData() { Value = 182.2, Name = "Aug" },
                        //        new SerieData() { Value = 48.7, Name = "Sep" },
                        //        new SerieData() { Value = 18.8, Name = "Oct" },
                        //        new SerieData() { Value = 6.0, Name = "Nov" },
                        //        new SerieData() { Value = 2.3, Name = "Dec" },
                        //    },
                        //},
                        //new BarSerie()
                        //{
                        //    Name = "Test",
                        //    Type = SerieType.Line,
                        //    Data = new List<SerieData>() {
                        //        new SerieData() { Value = 20.3, Name = "Jan" },
                        //        new SerieData() { Value = 17.8, Name = "Feb" },
                        //        new SerieData() { Value = 24.2, Name = "Mar" },
                        //        new SerieData() { Value = 50.9, Name = "Apr" },
                        //        new SerieData() { Value = 76.3, Name = "May" },
                        //        new SerieData() { Value = 112.5, Name = "Jun" },
                        //        new SerieData() { Value = 143.6, Name = "Jul" },
                        //        new SerieData() { Value = 153.5, Name = "Aug" },
                        //        new SerieData() { Value = 90.5, Name = "Sep" },
                        //        new SerieData() { Value = 18.8, Name = "Oct" },
                        //        new SerieData() { Value = 9.5, Name = "Nov" },
                        //        new SerieData() { Value = 15.6, Name = "Dec" },
                        //    },
                        //},
                        //new BarSerie()
                        //{
                        //    Name = "Test2",
                        //    Type = SerieType.Line,
                        //    Data = new List<SerieData>() {
                        //        new SerieData() { Value = 2.4, Name = "Jan" },
                        //        new SerieData() { Value = 3.7, Name = "Feb" },
                        //        new SerieData() { Value = 14.2, Name = "Mar" },
                        //        new SerieData() { Value = 30.9, Name = "Apr" },
                        //        new SerieData() { Value = 56.3, Name = "May" },
                        //        new SerieData() { Value = 82.5, Name = "Jun" },
                        //        new SerieData() { Value = 180.5, Name = "Jul" },
                        //        new SerieData() { Value = 190.5, Name = "Aug" },
                        //        new SerieData() { Value = 46.3, Name = "Sep" },
                        //        new SerieData() { Value = 9.3, Name = "Oct" },
                        //        new SerieData() { Value = 9.5, Name = "Nov" },
                        //        new SerieData() { Value = 1.4, Name = "Dec" },
                        //    },
                        //},
                    },
                };
                model.PieOption = new EchartOption<PieSerie>()
                {
                    Tooltip = new Tooltip() { Formatter = "P1" },
                    Legend = new Legend() { Position = LegendPosition.BottomCenter },
                    Title = new Title() { Text = "饼状图", Subtext = "测试饼状图" },
                    Series = new List<PieSerie>()
                    {
                        //new PieSerie()
                        //{
                        //    Name = "Access From",
                        //    Radius = "50%",
                        //    Data = new List<SerieData>() {
                        //        new SerieData() { Value = 1048, Name = "Search Engine" },
                        //        new SerieData() { Value = 735, Name = "Direct" },
                        //        new SerieData() { Value = 580, Name = "Email" },
                        //        new SerieData() { Value = 484, Name = "Union Ads" },
                        //        new SerieData() { Value = 300, Name = "Video Ads" },
                        //    },
                        //    Type = SerieType.Pie,
                        //},
                         new PieSerie()
                        {
                            Name = "Access From",
                            Radius = "50%",
                            Data = new List<SerieData>() {
                                new SerieData() { Value = 1, Name = "Search Engine" },
                                new SerieData() { Value = 0, Name = "Direct" },
                                new SerieData() { Value = 0, Name = "Email" },
                                new SerieData() { Value = 0, Name = "Union Ads" },
                                new SerieData() { Value = 0, Name = "Video Ads" },
                            },
                            Type = SerieType.Pie,
                        },
                    },
                };
            }
        }
    }
}
